﻿#region Header
// ------------------------ Licence / Copyright ------------------------
// 
// ScrumTable for Scrum Meeting Support
// Copyright © HSR - Hochschule für Technik Rapperswil
// All Rights Reserved
// 
// Author:
//  Michael Gfeller Silvan Gehrig Patrick Boos
// 
// ---------------------------------------------------------------------
#endregion

#region Usings
using System.Windows;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using ScrumTable.UI.View.Converter;
#endregion

namespace ScrumTable.UI.ViewModel.Test
{
    /// <summary>
    /// Test the ConverterEnumEqual
    /// </summary>
    [TestClass]
    public class ConverterEnumEqualTest
    {
        #region Additional test attributes
        enum MyTestEnum
        {
            Value1, Value2
        }

        enum MyTestEnum2
        {
            Value1, Value2
        }
        #endregion


        #region Methods
        //--------------------------------------------------------------------
        // Methods
        //--------------------------------------------------------------------

        [TestMethod]
        public void TestSameEnumTypeSameValueBool()
        {
            const MyTestEnum e1 = MyTestEnum.Value1;
            const MyTestEnum e2 = MyTestEnum.Value1;

            var convertor = new ConverterEnumEqual();
            var result = convertor.Convert(e1, typeof(bool), e2, null);

            Assert.AreEqual(true, (bool)result);
        }

        [TestMethod]
        public void TestSameEnumTypeDifferentValueBool()
        {
            const MyTestEnum e1 = MyTestEnum.Value1;
            const MyTestEnum e2 = MyTestEnum.Value2;

            var convertor = new ConverterEnumEqual();
            var result = convertor.Convert(e1, typeof(bool), e2, null);

            Assert.AreEqual(false, (bool)result);
        }

        [TestMethod]
        public void TestDifferentEnumTypeSameValueBool()
        {
            const MyTestEnum e1 = MyTestEnum.Value1;
            const MyTestEnum2 e2 = MyTestEnum2.Value1;

            var convertor = new ConverterEnumEqual();
            var result = convertor.Convert(e1, typeof(bool), e2, null);

            Assert.AreEqual(false, (bool)result);
        }

        [TestMethod]
        public void TestDifferentEnumTypeDifferentValueBool()
        {
            const MyTestEnum e1 = MyTestEnum.Value1;
            const MyTestEnum2 e2 = MyTestEnum2.Value2;

            var convertor = new ConverterEnumEqual();
            var result = convertor.Convert(e1, typeof(bool), e2, null);

            Assert.AreEqual(false, (bool)result);
        }

        [TestMethod]
        public void TestSameEnumTypeSameValueVisibility()
        {
            const MyTestEnum e1 = MyTestEnum.Value1;
            const MyTestEnum e2 = MyTestEnum.Value1;

            var convertor = new ConverterEnumEqual();
            var result = convertor.Convert(e1, typeof(Visibility), e2, null);

            Assert.AreEqual(Visibility.Visible, (Visibility)result);
        }

        [TestMethod]
        public void TestSameEnumTypeDifferentValueVisibility()
        {
            const MyTestEnum e1 = MyTestEnum.Value1;
            const MyTestEnum e2 = MyTestEnum.Value2;

            var convertor = new ConverterEnumEqual();
            var result = convertor.Convert(e1, typeof(Visibility), e2, null);

            Assert.AreEqual(Visibility.Collapsed, (Visibility)result);
        }

        [TestMethod]
        public void TestDifferentEnumTypeSameValueVisibility()
        {
            const MyTestEnum e1 = MyTestEnum.Value1;
            const MyTestEnum2 e2 = MyTestEnum2.Value1;

            var convertor = new ConverterEnumEqual();
            var result = convertor.Convert(e1, typeof(Visibility), e2, null);

            Assert.AreEqual(Visibility.Collapsed, (Visibility)result);
        }

        [TestMethod]
        public void TestDifferentEnumTypeDifferentValueVisibility()
        {
            const MyTestEnum e1 = MyTestEnum.Value1;
            const MyTestEnum2 e2 = MyTestEnum2.Value2;

            var convertor = new ConverterEnumEqual();
            var result = convertor.Convert(e1, typeof(Visibility), e2, null);

            Assert.AreEqual(Visibility.Collapsed, (Visibility)result);
        }


        [TestMethod]
        public void TestStringSameValueValueBool()
        {
            const MyTestEnum e1 = MyTestEnum.Value1;
            const string e2 = "Value1";

            var convertor = new ConverterEnumEqual();
            var result = convertor.Convert(e1, typeof(bool), e2, null);

            Assert.AreEqual(true, (bool)result);
        }

        [TestMethod]
        public void TestStringMultipleValuesOneSameValueBool()
        {
            const MyTestEnum e1 = MyTestEnum.Value1;
            const string e2 = "Value1,Value2";

            var convertor = new ConverterEnumEqual();
            var result = convertor.Convert(e1, typeof(bool), e2, null);

            Assert.AreEqual(true, (bool)result);
        }

        [TestMethod]
        public void TestStringMultipleValuesAllWrongValueBool()
        {
            const MyTestEnum e1 = MyTestEnum.Value1;
            const string e2 = "Value2,Value3";

            var convertor = new ConverterEnumEqual();
            var result = convertor.Convert(e1, typeof(bool), e2, null);

            Assert.AreEqual(false, (bool)result);
        }

        [TestMethod]
        public void TestStringDifferentValueValueBool()
        {
            const MyTestEnum e1 = MyTestEnum.Value1;
            const string e2 = "Value2";

            var convertor = new ConverterEnumEqual();
            var result = convertor.Convert(e1, typeof(bool), e2, null);

            Assert.AreEqual(false, (bool)result);
        }
        #endregion
    }
}
